package JDk8新时间.Duration;

import java.time.Duration;
import java.time.LocalDateTime;

public class Test {
    public static void main(String[] args) {
        LocalDateTime start = LocalDateTime.of(2025,11,11,11,10,10);
        LocalDateTime end = LocalDateTime.of(2025,11,11,11,11,11);

        // 1. 得到Duration对象
        Duration duration = Duration.between(start, end);

        // 2. 获取两个时间对象间隔的信息
        System.out.println(duration.toDays());// 间隔多少天
        System.out.println(duration.toHours());// 小时
        System.out.println(duration.toMinutes());// 分
        System.out.println(duration.toSeconds());// 秒
        System.out.println(duration.toMillis());// 毫秒
        System.out.println(duration.toNanos());// 纳秒
    }
}
